package com.example.diabeco;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class BaseDeDatos extends SQLiteOpenHelper {
    String sqlCreate = "CREATE TABLE alarmas (_id INTEGER PRIMARY KEY AUTOINCREMENT, hora TEXT, dias TEXT)";
    String sqlUpdate = "ALTER TABLE alarmas ADD COLUM fecha";
    
	// If you change the database schema, you must increment the database version.
    public static final int DATABASE_VERSION = 1;
    public static final String DATABASE_NAME = "Alarmas.db";
    
    public BaseDeDatos(Context context, String dbName, CursorFactory cFactory, int Version) {
        super(context, dbName, cFactory, Version);
    }
    
    @Override
    public void onCreate(SQLiteDatabase db) {
    	if (db.isReadOnly()) {
			db = getWritableDatabase();
		}
        db.execSQL(sqlCreate);
    }
    
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    	//Borrar y volver a crear 
//        db.execSQL(SQL_DELETE_ENTRIES);
//        onCreate(db);
    	
    	//Update
    	if (newVersion > oldVersion) {
//			db.execSQL(sqlUpdate)
		}
    }
    
    public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        onUpgrade(db, oldVersion, newVersion);
    }    
}
